import static CloudToolsPluginUtil.withCluster

grailsHome = Ant.project.properties."environment.GRAILS_HOME"

pluginHome = new File("./plugins").listFiles().find { it.name.startsWith('cloud-tools-')}

includeTargets << new File ( "${pluginHome}/scripts/ExplodedWar.groovy" ) 

target('default': "Redeploy the cluster") {
    doStuff()
}

target(doStuff: "The implementation task") {
  depends( explodedWar )
    // TODO - Fix for grails bug
    Ant.replace(file: "explodedWar/${grailsAppName}/WEB-INF/web.xml", token: "log4jConfigLocation", value: "log4jConfigLocationCloudToolsPluginUtil")
    withCluster { clusterManager, clusterName, cluster ->
        cluster.redeploy()
    }
    event("StatusFinal", ["Finished redeploying cluster"])

}